<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <form action="" name="myform">
        <input type="text" id="year"> 年
        <input type="text" id="month"> 月
        <input type="text" id="day"> 日
        <button type="button" onclick="calculatingTime()">计算</button>
    </form>

    <script>
        function calculatingTime() {
            var today = new Date();
            const year = today.getFullYear();
            const month = today.getMonth() + 1;
            const day = today.getDate();

            var year1 = Number(document.getElementById("year").value);
            var month1 = Number(document.getElementById("month").value);
            var day1= Number(document.getElementById("day").value);


            const etime = Date.parse(new Date(year+"-" +month+"-" +day+' 00:00:00'))
            const stime = Date.parse(new Date(year1+"-" +month1+"-" +day1+' 00:00:00'))
            const usedTime = etime - stime
            const days = Math.floor(usedTime / (24 * 3600 * 1000))

            alert( " 相差：" + days + "天")



        }
    </script>

</div>
</body>
</html>
